package com.ruoyi.web.controller.examine;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.examine.domain.TbStudentCheck;
import com.ruoyi.examine.service.ITbStudentCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学生检查Controller
 *
 * @author hongyi
 * @date 2023-12-28
 */
@RestController
@RequestMapping("/examine/check01")
public class TbStudentCheckController extends BaseController
{
    @Autowired
    private ITbStudentCheckService tbStudentCheckService;

    /**
     * 查询学生检查列表
     */
    @PreAuthorize("@ss.hasPermi('examine:check01:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbStudentCheck tbStudentCheck)
    {
        startPage();
        List<TbStudentCheck> list = tbStudentCheckService.selectTbStudentCheckList(tbStudentCheck);
        return getDataTable(list);
    }

    /**
     * 导出学生检查列表
     */
    @PreAuthorize("@ss.hasPermi('examine:check01:export')")
    @Log(title = "学生检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbStudentCheck tbStudentCheck)
    {
        List<TbStudentCheck> list = tbStudentCheckService.selectTbStudentCheckList(tbStudentCheck);
        ExcelUtil<TbStudentCheck> util = new ExcelUtil<TbStudentCheck>(TbStudentCheck.class);
        util.exportExcel(response, list, "学生检查数据");
    }

    /**
     * 获取学生检查详细信息
     */
    @PreAuthorize("@ss.hasPermi('examine:check01:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbStudentCheckService.selectTbStudentCheckById(id));
    }

    /**
     * 新增学生检查
     */
    @PreAuthorize("@ss.hasPermi('examine:check01:add')")
    @Log(title = "学生检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbStudentCheck tbStudentCheck)
    {
        return toAjax(tbStudentCheckService.insertTbStudentCheck(tbStudentCheck));
    }

    /**
     * 修改学生检查
     */
    @PreAuthorize("@ss.hasPermi('examine:check01:edit')")
    @Log(title = "学生检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbStudentCheck tbStudentCheck)
    {
        return toAjax(tbStudentCheckService.updateTbStudentCheck(tbStudentCheck));
    }

    /**
     * 删除学生检查
     */
    @PreAuthorize("@ss.hasPermi('examine:check01:remove')")
    @Log(title = "学生检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbStudentCheckService.deleteTbStudentCheckByIds(ids));
    }
}
